/**
 * @file 	 portserial.c
 * @brief    freemodbus 协议栈平台适配层
 * @author 	 wenbo
 * @version  1.0
 * @date 	 2023-03-21
 *
 * @copyright Copyright (c) 2023  YGL
 *
 */

#include "mbrtu.h"
#include "fmb_port.h"
#include "xp_lpuart.h"

eMBErrorCode eMBRTU_PortInit(UCHAR port, ULONG baudRate, eMBParity parity)
{
	Init_LPUART(port, baudRate, parity);
	return MB_ENOERR;
}

void eMBRTU_PortDeInit(UCHAR port)
{
	// 暂时未实现
}

eMBErrorCode eMBRTU_SendCB(UCHAR port, UCHAR* pData, ULONG size)
{
	return push_to_tx_ringbuffer(port, pData, size) ? MB_ENOERR : MB_EIO;
}

void* eMB_Malloc(ULONG size)
{
	return aos_malloc(size);
}

void eMB_Free(void *p)
{
	aos_free(p);
}
